import numpy as np
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab

# 绘图参数全家桶
params = {
    'axes.labelsize': '14',
    'xtick.labelsize': '12',
    'ytick.labelsize': '12',
    'legend.fontsize': '12',
    'figure.figsize': '6, 4',
    'figure.dpi': '180',
    'figure.subplot.left': '0.154',
    'figure.subplot.right': '0.982',
    'figure.subplot.bottom': '0.219',
    'figure.subplot.top': '0.974',
    'pdf.fonttype': '42',
    'ps.fonttype': '42',
    'font.family': ['Times New Roman', 'SimSun'],
    'mathtext.fontset': 'cm'
}
pylab.rcParams.update(params)

color_1 = "#FF6666"
color_2 = "#EE9966"
color_3 = "#EECC66"
color_4 = "#66CC99"
color_5 = "#6699FF"
color_6 = "#9966FF"

fig, ax = plt.subplots()

# 折线图
x = np.arange(10) + 1  # the label locations
data = [[10.01, 12.02, 68.41, 96.09, 99.6, 99.9, 99.76, 100.0, 100.0, 100.0],
        [10.32, 10.04, 11.89, 77.1, 99.77, 99.89, 99.97, 99.99, 100.0, 100.0],
        [9.81, 9.79, 10.17, 27.55, 96.85, 99.97, 100.0, 100.0, 100.0, 100.0],
        [9.6, 9.49, 9.91, 9.87, 11.28, 20.02, 99.14, 100.0, 100.0, 100.0],
        [9.97, 9.87, 9.86, 9.85, 9.71, 9.78, 9.73, 9.75, 9.8, 9.9]]
plt.plot(x, data[0], linewidth=2.0, color=color_1, marker='o',
         markerfacecolor=color_1, markeredgewidth=1.5, markersize=8, label='$alpha=1.0$')
plt.plot(x, data[1], linewidth=2.0, color=color_2, marker='o',
         markerfacecolor=color_2, markeredgewidth=1.5, markersize=8, label="$alpha=0.8$")
plt.plot(x, data[2], linewidth=2.0, color=color_3, marker='o',
         markerfacecolor=color_3, markeredgewidth=1.5, markersize=8, label="$alpha=0.6$")
plt.plot(x, data[3], linewidth=2.0, color=color_4, marker='o',
         markerfacecolor=color_4, markeredgewidth=1.5, markersize=8, label="$alpha=0.4$")
plt.plot(x, data[4], linewidth=2.0, color=color_5, marker='o',
         markerfacecolor=color_5, markeredgewidth=1.5, markersize=8, label="$alpha=0.2$")

ax.set_xticks([0, 2, 4, 6, 8, 10])
ax.set_xticklabels(['$0$', '$2$', '$4$', '$6$', '$8$', '$10$'])
ax.set_yticks([0, 20, 40, 60, 80, 100])
ax.set_yticklabels(['$0\\text{%}$',
                    '$20\\text{%}$',
                    '$40\\text{%}$',
                    '$60\\text{%}$',
                    '$80\\text{%}$',
                    '$100\\text{%}$'])
ax.set_xlabel('Epoch Number')
ax.set_ylabel('Attack Success Rate')

plt.xlim((0, 11))
plt.ylim((0, 110))

plt.legend(loc='upper left', ncol=1, columnspacing=1, prop={'size': 10})

plt.grid(linestyle="--", linewidth=0.5, color='black', alpha=0.5)

plt.tight_layout()

plt.savefig("./alpha-2.png", format='png')

plt.show()
